<template>
<div class="merchandise-categorieslower-add views-container">
    <div class="wlm-form">
        <div class="wlm-form-header">{{`${!!formFormatData.api['editForm']['params']['category_id']?'编辑':'添加'}分类`}}</div>
        <div class="wlm-form-content">
            <el-form :ref="formFormatData.key" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="120px" class="retail-form" label-position="right">
                <el-form-item label="上级分类">
                    <!-- <el-input :readonly="true" v-model.trim="formFormatData.formData.username">
                    </el-input> -->
                    <span style="color:#409EFF;">{{$route.query.name || (formFormatData.formData.parent_name?formFormatData.formData.parent_name.name:'')}}</span>
                </el-form-item>
                <el-form-item label="分类名称">
                    <el-input  v-model.trim="formFormatData.formData.name">
                    </el-input>
                </el-form-item>
                <el-form-item label="分类图片">
                    <choose-files ref="chooseFiles" :config="chooseLogoConfig" :changeEvt="formFormatFiltersChange"></choose-files>
                    <div class="form-help">建议尺寸400*400</div>
                </el-form-item>
                <el-form-item label="状态">
                    <el-radio-group v-model="formFormatData.formData.status">
                        <el-radio :label="1">启用</el-radio>
                        <el-radio :label="0">禁用</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="排序">
                    <el-input v-model.trim="formFormatData.formData.sort">
                    </el-input>
                </el-form-item>
            </el-form>
        </div>
    </div>
    <div v-cloak class="wlm-fixed-btn flex-row flex-align-c flex-justify-c">
        <el-button size="small" @click="formFormatSubmit({ router: { type: 'replace', path: '/merchandise/merchandiseCategories', code: 1 }})" type="primary">保存</el-button>
        <router-link tag="span" to="/merchandise/merchandiseCategories">
            <el-button size="small">返回</el-button>
        </router-link>
    </div>
</div>
</template>

<script>
import ChooseFiles from '@/components/ChooseFiles/index'
import {
  goodsclassEdit,
  goodsclassGet
} from '@/api/merchandise'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Form')],
  name: 'ManagementUserAdd',
  components: {
    ChooseFiles
  },
  directives: {

  },
  data() {
    return {
      chooseLogoConfig: {
        type: ['image'],
        model: 'display',
        uploadConfig: {
          limit: 1,
          model: 'display'
        },
        initList: [],
        isShowList: true,
        file_type: 'image',
        bindKey: {
          key: 'image',
          model: 'img'
        }
      },
      formFormatData: {
        key: 'userForm',
        api: {
          editForm: {
            api: goodsclassGet,
            params: {
              parent_id: this.$route.query.parent_id,
              category_id: this.$route.query.category_id
            },
            filters: {
              img: {
                bindInit: ['chooseLogoConfig']
              }
            },
            noFilter: ['parent_name'],
            redirect: 'category_id'
          },
          submitForm: goodsclassEdit
        },
        formData: {
          parent_id: this.$route.query.parent_id,
          name: '',
          sort: '',
          image: [],
          status: 1
        },
        rules: {
          // nickname: [{
          //   required: true,
          //   message: '请输入真实姓名',
          //   trigger: 'blur'
          // }]
        }
      }
    }
  },
  methods: {
    uploadPlatformChange(imgs) {

    }
  }
}
</script>

<style lang="scss" scoped>
.merchandise-categorieslower-add {}
</style>
